package org.example.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.entity.GameRecord;
import org.example.mapper.GameRecordMapper;
import org.springframework.stereotype.Service;

@Service
public class GameRecordService extends ServiceImpl<GameRecordMapper, GameRecord> {

    // 自定义方法可以继续保留
    public GameRecord findTopByUsernameOrderByIdDesc(String username) {
        // 使用MyBatis-Plus的查询构造器
        return lambdaQuery()
                .eq(GameRecord::getUsername, username)
                .orderByDesc(GameRecord::getId)
                .last("LIMIT 1")
                .one();
    }
}